home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FM Towns: Free Software Collection 9
/
FM Towns Free Software Collection 9.iso
/
t_os
/
tool
/
vdgear
/
src
/
window.c
< prev
Wrap
Text File
|
1994-11-16
|
19KB
|
867 lines
/*
* VIDEO・GEAR
* "window.c"
* by Good-Chy
*/
#include "video.h"
FILE *pf_t;
char *tiff;
char *picture_name;
EFFECT effect_buf;
PICTURE picture_buf1, picture_buf2;
MIXING mixing_buf;
SOUND sound_buf;
CD cd_buf;
/******************************************************************************
* エラ-ウィンドウ
*/
void err_window(int err, int x, int y)
{
BUTTON *p;
p = window_open(x,y,200,45,324,0);
p = create(p, 84,24,32,17, 0, close);
sprint(err_msg[err],x+6,y+17,15,8,12,12,4);
}
/******************************************************************************
* 確認ウィンドウ
*/
void con_win(int con)
{
BUTTON *p;
p = window_open(230,217,177,45,324,50);
switch(con)
{
case 0:p = create(p, 41,22,32,17,0,pro_exit); break;
case 1:p = create(p, 41,22,32,17,0,all_clear_sub); break;
case 2:p = create(p, 41,22,32,17,0,data_load); break;
case 3:p = create(p, 41,22,32,17,0,data_save); break;
case 4:p = create(p, 41,22,32,17,0,data_save); break;
}
p = create(p,111,22,31,17,0,close);
sprint(con_msg[con],238,233,15,8,12,12,4);
}
/******************************************************************************
* エフェクトリストのウィンドウ
*/
void set_effect() /* エフェクト一覧で設定された */
{
char sel;
int x, y;
sel = win[active].last->number;
effect_buf.effect = sel+1;
picture_buf1.effect = sel+1;
close();
x = win[active].last->bx;
y = win[active].last->by;
EGB_paintMode(egb_work,0x22);
box_full(x+1,y+1,x+119,y+12,4,4,0);
sprint(eff_str[sel],x,y+12,15,8,12,12,4);
}
void effect() /* エフェクト一覧表を開く */
{
BUTTON *p;
int wy,i,j;
wy = win[active].last->by+17;
p = window_open(126,wy,388,119,0,97);
for (i=0 ; i<5 ; i++)
{
for (j=0 ; j<3 ; j++)
{
p = create(p, j*127+7, i*17+33, 120, 13, 0, set_effect);
}
}
p = create(p, 350, 8, 31, 17, 0, close);
}
/******************************************************************************
* パソコン画像ウィンドウ
*/
char *pic_name(char *name) /* フルパスからファイル名を取り出す */
{
int len;
len = strlen(name);
while((*(name+len) != '\\') && (len>0)) { len--; }
return (name+len+1);
}
void picture_print(int stp, int x, int y) /* 絵を表示する */
{
int dx,dy;
char *p;
dx = stp % 8 * 40;
dy = stp / 8 * 30+60;
EGB_writePage(egb_work,0x81);
p = get_vram(32,dx,dy,dx+39,dy+29);
EGB_writePage(egb_work,1);
put_vram(p,x,y,x+39,y+29);
EGB_writePage(egb_work,0);
free(p);
}
void pic_close() /* 縮小表示ウィンドウを閉める */
{
int x1,x2,y1,y2;
x1 = win[active].wx/2;
y1 = win[active].wy/2;
x2 = win[active].dx/2;
y2 = win[active].dy/2;
EGB_paintMode(egb_work,0x22);
EGB_writePage(egb_work,1);
box_full(x1,y1,x1+x2,y1+y2,0x8000,0x8000,0);
EGB_writePage(egb_work,0);
free(tiff);
close();
}
void pic_set_pos() /* 絵の表示位置を決定する */
{
int wx,wy;
picture_buf1.x = picture_buf2.x;
picture_buf1.y = picture_buf2.y;
strcpy(picture_buf1.name, picture_buf2.name);
pic_close();
wx = win[active].wx;
wy = win[active].wy;
EGB_paintMode(egb_work,0x22);
box_full(wx+87,wy+53,wx+205,wy+65,4,4,0);
box_full(wx+87,wy+70,wx+205,wy+82,4,4,0);
sprint(pic_name(picture_buf1.name),wx+87,313,15,8,12,12,4);
sprint("X: Y:",wx+87,330,15,8,12,12,4);
sprintusing(picture_buf1.x*2,3,wx+111,330,15,8,12,12,4);
sprintusing(picture_buf1.y*2,3,wx+159,330,15,8,12,12,4);
}
void set_pos() /* 絵の表示位置を変更する */
{
int ch,x,y,tx,ty,wx,wy;
MOS_rdpos(&ch,&x,&y);
tx = WORD(tiff+0)+1;
ty = WORD(tiff+2)+1;
wx = win[active].wx;
wy = win[active].wy;
x = x-wx-2-tx/4;
y = y-wy-27-ty/4;
if (x<0) { x = 0; }
if (y<0) { y = 0; }
if ((x+tx/2)>159) { x = 160-tx/2; }
if ((y+ty/2)>119) { y = 120-ty/2; }
EGB_writePage(egb_work,1);
EGB_paintMode(egb_work,0x22);
box_full((wx+2)/2,(wy+28)/2,(wx+2)/2+80,(wy+28)/2+60,0x8000,0x8000,0);
put_vram_zoom((tiff+6),(wx+2+x)/2,(wy+28+y)/2,
(wx+2+x)/2+tx/4-1,(wy+28+y)/2+ty/4-1,tx,ty);
EGB_writePage(egb_work,0x81);
box_full(280,30,319,59,0x8000,0x8000,0);
put_vram_zoom((tiff+6),x/4+280,y/4+30,x/4+tx/8+279,y/4+ty/8+29,tx,ty);
EGB_writePage(egb_work,0);
picture_buf2.x = x;
picture_buf2.y = y;
}
void picture_pos(char *name) /* 絵を縮小表示ウィンドウに読み込む */
{
BUTTON *p;
int x,y,tx,ty,wx,en;
wx = win[1].wx;
p = window_open(wx+24,314,163,148,0,330);
p = create(p,2,27,159,119,0,set_pos);
p = create(p, 92,4,32,17,0,pic_set_pos);
p = create(p,128,4,31,17,0,pic_close);
p = create(p,128,4,31,17,0,close);
sprint(pic_name(name),wx+29,331,15,8,12,12,0);
if (NULL == (tiff = tiff_load(name))) /* 読み込みに失敗 */
{
close();
if (err == 1) { en = 1; }
if (err == 2) { en = 5; }
if (err == 3) { en = 6; }
err_window(en,wx+5,303);
setmos(81);
return;
}
x = WORD(tiff+0)+1;
y = WORD(tiff+2)+1;
if (WORD(tiff+4) != 16) /* 32k色以外 */
{
close();
err_window(6,wx+5,303);
free(tiff);
setmos(81);
return;
}
if ((x>320) || (y>240)) /* サイズが大きい */
{
close();
err_window(7,wx+5,303);
free(tiff);
setmos(81);
return;
}
tx = picture_buf1.x*2;
ty = picture_buf1.y*2;
if (x+tx>320) { tx = 0; }
if (y+ty>240) { ty = 0; }
EGB_writePage(egb_work,1);
put_vram_zoom((tiff+6),(wx+26)/2+tx/4,171+ty/4,
x/4+(wx+26)/2+tx/4-1,y/4+ty/4+170,x,y);
EGB_writePage(egb_work,0x81);
EGB_paintMode(egb_work,0x22);
box_full(280,30,319,59,0x8000,0x8000,0);
put_vram_zoom((tiff+6),tx/8+280,ty/8+30,(tx+x)/8+279,(ty+y)/8+29,x,y);
EGB_writePage(egb_work,0);
picture_buf2.x = tx/2;
picture_buf2.y = ty/2;
}
void picture_load() /* 絵を読み込む */
{
char *crrdir = NULL;
close();
crrdir = _getcwd(crrdir,256);
if (strlen(crrdir) > 3) { strcat(crrdir,"\\"); }
strcat(crrdir,key_buff);
strcpy(picture_buf2.name, crrdir);
picture_pos(crrdir);
}
void picture_clear() /* 消去 */
{
int wx,wy;
close();
picture_buf1.x = 0;
picture_buf1.y = 0;
strcpy(picture_buf1.name,"消去");
EGB_writePage(egb_work,0x81);
EGB_paintMode(egb_work,0x22);
box_full(280,30,319,59,0x8000,0x8000,0);
sprint("消去",284,52,0x7fff,0,16,16,1);
EGB_writePage(egb_work,0);
wx = win[active].wx;
wy = win[active].wy;
box_full(wx+87,wy+53,wx+205,wy+65,4,4,0);
sprint("消去",wx+87,313,15,8,12,12,4);
}
void picture_load_sel()
{
file_sel(2);
}
void picture_sel()
{
BUTTON *p;
int wx,wy;
wx = win[1].wx+121;
wy = win[active].last->by+14;
p = window_open(wx,wy,50,63,526,0);
p = create(p,6,6,38,15,1,picture_load_sel);
p = create(p,6,23,38,15,1,picture_clear);
p = create(p,12,41,31,17,0,close);
}
void position()
{
if (picture_buf1.name[0] != '\0')
{
if (strcmp(picture_buf1.name,"消去") != 0)
{
strcpy(picture_buf2.name, picture_buf1.name);
picture_pos(picture_buf1.name);
}
}
}
void set_picture() /* パソコン画像ウィンドウで設定が押された */
{
int x,y, vx, stp;
char *p;
if ((picture_buf1.effect == 0) || (picture_buf1.name[0] == '\0'))
{
vx = win[1].wx;
err_window(0,vx+5,280);
}
else
{
stp = step + (win[0].last->number)/5;
data[stp].picture.flag = 1;
data[stp].picture.effect = picture_buf1.effect;
data[stp].picture.x = picture_buf1.x;
data[stp].picture.y = picture_buf1.y;
strcpy(data[stp].picture.name, picture_buf1.name);
close();
x = stp % 8 * 40;
y = stp / 8 * 30+60;
EGB_writePage(egb_work,0x81);
p = get_vram(32,280,30,319,59);
put_vram(p,x,y,x+39,y+29);
free(p);
picture_print(stp,((win[0].last->number/5)*89+102)/2,91);
EGB_writePage(egb_work,0);
}
}
void picture() /* パソコン画像のウィンドウを開く */
{
BUTTON *p;
int wx, stp;
char *pic;
int x,y;
wx = win[active].last->bx-65;
p = window_open(wx,248,211,110,0,218);
p = create(p,86,35,120,14,0,effect);
p = create(p,86,52,120,14,0,picture_sel);
p = create(p,86,69,120,14,0,position);
p = create(p,137,89,32,17,0,set_picture);
p = create(p,173,89,31,17,0,close);
stp = step + (win[0].last->number)/5;
if (data[stp].picture.flag == 1)
{
picture_buf1.effect = data[stp].picture.effect;
picture_buf1.x = data[stp].picture.x;
picture_buf1.y = data[stp].picture.y;
strcpy(picture_buf1.name, data[stp].picture.name);
sprint(eff_str[picture_buf1.effect-1],wx+86,295,15,8,12,12,4);
if (strcmp(picture_buf1.name,"消去") != 0)
{
sprint(pic_name(picture_buf1.name),wx+87,313,15,8,12,12,4);
sprint("X: Y:",wx+87,330,15,8,12,12,4);
sprintusing(picture_buf1.x*2,3,wx+111,330,15,8,12,12,4);
sprintusing(picture_buf1.y*2,3,wx+159,330,15,8,12,12,4);
}
else
{
sprint("消去",wx+87,313,15,8,12,12,4);
}
x = stp % 8 * 40;
y = stp / 8 * 30+60;
EGB_writePage(egb_work,0x81);
pic = get_vram(32,x,y,x+39,y+29);
put_vram(pic,280,30,319,59);
free(pic);
EGB_writePage(egb_work,0);
}
else
{
picture_buf1.effect = 0;
picture_buf1.x = 0;
picture_buf1.y = 0;
picture_buf1.name[0] = '\0';
}
}
/******************************************************************************
* ビデオ画像ウィンドウ
*/
void simpose() /* ス-パ-インポ-ズの設定 */
{
int x,y;
effect_buf.spimpose = 1-effect_buf.spimpose;
x = win[active].last->bx;
y = win[active].last->by;
EGB_paintMode(egb_work,0x22);
box_full(x+1,y+1,x+119,y+12,4,4,0);
sprint(state[effect_buf.spimpose],x,y+12,15,8,12,12,4);
}
void effect_print(int effect, int x, int y)
{
char *p;
int dx,dy;
dx = ((effect)%8)*40;
dy = (effect /8)*30;
EGB_writePage(egb_work,0x81);
p = get_vram(32,dx,dy,dx+39,dy+29);
EGB_writePage(egb_work,1);
put_vram(p,x,y,x+39,y+29);
EGB_writePage(egb_work,0);
free(p);
}
void set_video() /* 設定ボタンが押された */
{
int stp, vx,dx,dy;
if (effect_buf.effect == 0)
{
vx = win[1].wx;
err_window(0,vx+34,230);
}
else
{
stp = step + (win[0].last->number)/5;
data[stp].effect.flag = 1;
data[stp].effect.effect = effect_buf.effect;
data[stp].effect.spimpose = effect_buf.spimpose;
dx = win[0].last->bx/2;
dy = win[0].last->by/2;
effect_print(effect_buf.effect-1,dx,dy);
close();
}
}
void video_win() /* ビデオ画像ウィンドウを開く */
{
BUTTON *p;
int vx, stp;
vx = win[active].last->bx - 85;
p = window_open(vx,178,246,95,76,0);
p = create(p, 121, 35,120, 13, 0, effect);
p = create(p, 121, 51,120, 13, 0, simpose);
p = create(p, 171, 74, 32, 17, 0, set_video);
p = create(p, 206, 74, 32, 17, 0, close);
stp = step + (win[0].last->number)/5;
if (data[stp].effect.flag == 1)
{
effect_buf.effect = data[stp].effect.effect;
effect_buf.spimpose = data[stp].effect.spimpose;
sprint(eff_str[effect_buf.effect-1],vx+121,225,15,8,12,12,4);
}
else
{
effect_buf.effect = 0;
effect_buf.spimpose = 0;
}
sprint(state[effect_buf.spimpose],vx+121,241,15,8,12,12,4);
}
/******************************************************************************
* CDプレイヤウィンドウ
*/
void cd_print(int i)
{
int tr,st;
tr = data[step+i].cd.track+1;
st = data[step+i].cd.state;
switch(st)
{
case 0:sprint("PLAY ",i*89+104,275,13,0,16,16,1);
sprintusing(tr,2,i*89+164,275,15,0,16,16,1); break;
case 1:sprint(" STOP ",i*89+106,275,10,0,16,16,1); break;
case 2:sprint("FADE-IN",i*89+104,275,14,0,16,16,1);
sprintusing(tr,2,i*89+164,275,15,0,16,16,1); break;
case 3:sprint("FADE-OUT",i*89+110,275, 3,0,16,16,1); break;
}
}
void print_track(int tr) /* トラックナンバ-表示 */
{
int wx,wy;
wx = win[active].wx;
wy = win[active].wy;
EGB_paintMode(egb_work,0x22);
box_full(wx+90,wy+34,wx+111,wy+46,4,4,0);
sprintusing(tr,2,wx+90,wy+46,15,8,24,12,0);
}
void track_up() /* トラックナンバ アップ */
{
if (cd_buf.track<98) { cd_buf.track++; }
print_track(cd_buf.track+1);
}
void track_down() /* トラックナンバ- ダウン */
{
if (cd_buf.track>0) { cd_buf.track--; }
print_track(cd_buf.track+1);
}
void ch_state() /* 状態チェンジ */
{
int wx,wy;
cd_buf.state++;
if (cd_buf.state>3) { cd_buf.state = 0; }
wx = win[active].wx;
wy = win[active].wy;
EGB_paintMode(egb_work,0x22);
box_full(wx+59,wy+52,wx+142,wy+64,4,4,0);
sprint(state[cd_buf.state+2],wx+59,wy+64,15,8,12,12,4);
}
void cd_play()
{
play_cd_da(cd_buf.track);
}
void cd_stop()
{
setmos(82);
cdr_mstop(0);
setmos(81);
}
void cd_set() /* 設定ボタンが押された */
{
int stp,i;
i = (win[0].last->number)/5;
stp = step + i;
data[stp].cd.flag = 1;
data[stp].cd.track = cd_buf.track;
data[stp].cd.state = cd_buf.state;
EGB_paintMode(egb_work,0x22);
box_full(102+i*89,252,181+i*89,283,0,0,0);
cd_print(i);
close();
}
void cd_win()
{
BUTTON *p;
int vx, stp;
vx = win[active].last->bx - 34;
p = window_open(vx,288,148,91,374,218);
p = create(p, 72, 34, 12, 12, 2, track_down);
p = create(p, 117, 34, 12, 12, 2, track_up);
p = create(p, 58, 51, 85, 14, 0, ch_state);
p = create(p, 4, 70, 32, 17, 0, cd_play);
p = create(p, 40, 70, 32, 17, 0, cd_stop);
p = create(p, 77, 70, 32, 17, 0, cd_set);
p = create(p, 113, 70, 31, 17, 0, close);
stp = step + (win[0].last->number)/5;
if (data[stp].cd.flag == 1)
{
cd_buf.track = data[stp].cd.track;
cd_buf.state = data[stp].cd.state;
}
else
{
cd_buf.track = 0;
cd_buf.state = 0;
}
print_track(cd_buf.track+1);
sprint(state[cd_buf.state+2],vx+59,352,15,8,12,12,4);
}
/******************************************************************************
* 効果音ウィンドウ
*/
void disp_vol(int dx, int dy, int vol)
{
int co;
if (vol<24) { co = 11; }
else { co = 10; }
line(vol*2+dx, dy, vol*2+dx, dy+10, co);
}
void clear_vol(int dx,int dy, int vol)
{
line(vol*2+dx, dy, vol*2+dx, dy+10, 4);
}
void sound_vol_up()
{
int wx,wy;
wx = win[active].wx;
wy = win[active].wy;
if (sound_buf.vol < 31)
{
sound_buf.vol++;
disp_vol(wx+76, wy+51, sound_buf.vol);
}
}
void sound_vol_down()
{
int wx,wy;
wx = win[active].wx;
wy = win[active].wy;
if (sound_buf.vol > 0)
{
clear_vol(wx+76, wy+51, sound_buf.vol);
sound_buf.vol--;
}
}
void sound_print(int i)
{
sprint(pic_name(data[step+i].sound.name),i*89+106,316,15,0,12,12,0);
}
void sound_sel()
{
file_sel(3);
}
void sound_name() /* ファイル名の設定 */
{
int wx,wy;
char *crrdir = NULL;
close();
crrdir = _getcwd(crrdir,256);
if (strlen(crrdir) > 3) { strcat(crrdir,"\\"); }
strcat(crrdir,key_buff);
strcpy(sound_buf.name, crrdir);
wx = win[active].wx;
wy = win[active].wy;
EGB_paintMode(egb_work,0x22);
box_full(wx+65,wy+34,wx+142,wy+46,4,4,0);
sprint(pic_name(sound_buf.name),wx+65,wy+46,15,8,12,12,4);
}
void sound_play() /* PCM再生 */
{
int wx,wy;
SND_pcm_play_stop(71);
free(snd_bp);
if ((snd_bp = snd_load(sound_buf.name)) == NULL)
{
snd_bp = malloc(1); /* dummy */
wx = win[active].wx;
wy = win[active].wy;
switch(err)
{
case 1:err_window( 1,wx-26,wy+14); break;
case 2:err_window( 9,wx-26,wy+14); break;
case 3:err_window(10,wx-26,wy+14); break;
}
return;
}
snd_play(snd_bp,sound_buf.vol);
}
void sound_stop()
{
SND_pcm_play_stop(71);
}
void set_sound() /* 設定ボタンが押された */
{
int stp,i,wx,wy;
i = (win[0].last->number)/5;
stp = step + i;
wx = win[active].wx;
wy = win[active].wy;
if (strcmp(sound_buf.name,"") == 0)
{ err_window(8,wx-26,wy+14); }
else
{
data[stp].sound.flag = 1;
data[stp].sound.vol = sound_buf.vol;
strcpy(data[stp].sound.name,sound_buf.name);
EGB_paintMode(egb_work,0x22);
box_full(102+i*89,294,181+i*89,325,0,0,0);
sound_print(i);
close();
}
}
void sound_win()
{
BUTTON *p;
int i,vx, stp;
vx = win[active].last->bx - 34;
p = window_open(vx,330,159,94,165,330);
p = create(p, 60, 33, 94, 14, 0, sound_sel);
p = create(p, 60, 51, 12, 12, 2, sound_vol_down);
p = create(p, 142, 51, 12, 12, 2, sound_vol_up);
p = create(p, 6, 71, 32, 17, 0, sound_play);
p = create(p, 42, 71, 32, 17, 0, sound_stop);
p = create(p, 86, 71, 32, 17, 0, set_sound);
p = create(p, 122, 71, 31, 17, 0, close);
stp = step + (win[0].last->number)/5;
if (data[stp].sound.flag == 1)
{
sound_buf.vol = data[stp].sound.vol;
strcpy(sound_buf.name,data[stp].sound.name);
sprint(pic_name(sound_buf.name),vx+65,376,15,8,12,12,4);
if (sound_buf.vol>0)
{
for(i=1 ; i<sound_buf.vol+1 ; i++)
{
disp_vol(vx+76, 330+51, i);
}
}
}
else
{
sound_buf.vol = 0;
strcpy(sound_buf.name,"");
}
}
/******************************************************************************
* ミキシングウィンドウ
*/
void disp_all_vol()
{
int i,j, wx,wy, vol;
wx = win[active].wx;
wy = win[active].wy;
for (i=0 ; i<3 ; i++)
{
vol = mixing_buf.vol[i];
if (vol>0)
{
for(j=1 ; j<vol+1 ; j++)
{
disp_vol(wx+76,i*17+wy+33,j);
}
}
}
}
void vol_up()
{
int p,wx,wy;
p = (win[active].last->number)/2;
wx = win[active].wx;
wy = win[active].wy;
if (mixing_buf.vol[p] < 31)
{
mixing_buf.vol[p]++;
disp_vol(wx+76, p*17+wy+33, mixing_buf.vol[p]);
}
}
void vol_down()
{
int p,wx,wy;
wx = win[active].wx;
wy = win[active].wy;
p = (win[active].last->number)/2;
if (mixing_buf.vol[p] > 0)
{
clear_vol(wx+76, p*17+wy+33, mixing_buf.vol[p]);
mixing_buf.vol[p]--;
}
}
void set_mix()
{
int dx,dy, stp;
stp = step + (win[0].last->number)/5;
data[stp].mixing.flag = 1;
data[stp].mixing.vol[0] = mixing_buf.vol[0];
data[stp].mixing.vol[1] = mixing_buf.vol[1];
data[stp].mixing.vol[2] = mixing_buf.vol[2];
dx = win[0].last->bx;
dy = win[0].last->by;
sprint("設定あり",dx+8,dy+23,15,0,16,16,1);
close();
}
void mixing()
{
BUTTON *p;
int vx,stp,i;
vx = win[active].last->bx - 39;
p = window_open(vx,370,159,110,213,218);
for(i=0 ; i<3 ; i++)
{
p = create(p, 60, i*17+33,12, 12, 2, vol_down);
p = create(p, 142, i*17+33,12, 12, 2, vol_up);
}
p = create(p, 86, 87, 32, 17, 0, set_mix);
p = create(p, 122, 87, 31, 17, 0, close);
stp = step + (win[0].last->number)/5;
if (data[stp].mixing.flag == 1)
{
mixing_buf.vol[0] = data[stp].mixing.vol[0];
mixing_buf.vol[1] = data[stp].mixing.vol[1];
mixing_buf.vol[2] = data[stp].mixing.vol[2];
disp_all_vol();
}
else
{
mixing_buf.vol[0] = 0;
mixing_buf.vol[1] = 0;
mixing_buf.vol[2] = 0;
disp_all_vol();
}
}